<?php
/**
 * 默认控制器
 * @author Administrator
 *
 */
class main extends MY_Controller{
    function main(){
        parent::MY_Controller();
    }
    function index(){
        if ($this->user['userRole'] == 1){
            redirect(printUrl('ReachStore','storeList'));
        }else{
            redirect(printUrl('ReachStore','adminList'));
        }
        //echo $this->input->server('HTTP_REFERER');
        $this->load->view("Main/index");
    }
    function ajax(){
        $this->success("错误");
    }
    /**
     * rmp营销网首页提醒
     */
    function notice(){
        $return = array('status'=>0,'msg'=>'');
        if ($this->user['userRole'] != 1){
            echo jsonEncode($return);
            exit();
        }
        //查询条件
        $where = array('isDel'=>0,'status'=>1);
        //年份
        $year = $this->config->item('nowYear');
        $year && $where['year'] = $year;
        //时段
        //$timeUnit = (int)$this->input->get('timeUnit');
        
        //查询项目数据
        $this->load->model('projectModel');
        $proList = $this->projectModel->getNewList($where, NULL, NULL, '', 'proId desc');
        //查询专营店项目数据
        $this->load->model('storeProModel');
        $storeProList = $this->storeProModel->getProListKeyProId($this->user['userId']);
        //筛选出各审核状态的数据
        $list1 = array();$list2 = array();$list3 = array();
        foreach ($proList as $v){
            $v['proId'] = (int)$v['proId'];
            if (isset($storeProList[$v['proId']])){
                $storeProData = $storeProList[$v['proId']];
                if ($storeProData['auditRs'] == -1){//未提交
                    $list1[] = $v;
                }else if ($storeProData['auditRs'] == 0){//待审核
                    $v['storeData'] = $storeProData;
                    $list2[] = $v;
                }else{//已审核
                    $v['storeData'] = $storeProData;
                    $list3[] = $v;
                }
            }else{
                $list1[] = $v;
            }
        }
        if ($list1){
            $return['status'] = 1;
            $return['msg'] = 'RMP端执行反馈系统有新的反馈内容需要填写'; 
            echo jsonEncode($return);
            exit();
        }
        echo jsonEncode($return);
        exit();
    }
    function testEmail(){
        $this->load->library('email');
        
        $this->email->from('dflpvmkt@bluedoorinteractive.cn', '东风日产营销网');
        $this->email->to('421253081@qq.com');
        //$this->email->cc('another@another-example.com');
        //$this->email->bcc('them@their-example.com');
        
        $this->email->subject('测试标题');
        $this->email->message('测试内容');
        
        $this->email->send();
        echo $this->email->print_debugger();
        /* $emailCon = $this->config->item('emailConfig');
        $this->load->library('SMTPMail', $emailCon, 'SMTPMail');
        $title = '测试标题';
        $content = '测试内容';
        
        $this->SMTPMail->SendMail("dflpvmkt@bluedoorinteractive.cn", "421253081@qq.com" ,$title, $content, '东风日产营销网'); */
        
    }
}